#region Developer's comment header
/* ItersManager.cs
 * 
 * author:    DS2171
 * copyright: DS2171
 * 
 * history:   15/11/2010, DS2171: Created.
 *
 */
#endregion
#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml.Serialization;

using Chili.Opf3;
using Chili.Opf3.Relations;


#endregion

namespace DocManagerORM.Entità
{
	/// <summary>
	/// Persistent object for the "ItersManager" table.
	/// </summary>
	[Serializable]
	[Persistent("ItersManager")]
	public partial class ItersManager : IObjectNotification, ISelfContainingObject, INotifyPropertyChanged, IItersManager
	{
		#region Fields

		private int _id;
		private int _fk_IDDoc;
		private Guid _fk_IDUser_Mittente = Guid.NewGuid();
		private string _userName;
		private string _titolo;
		private DateTime? _dataCreazione;
		private DateTime? _dataScadenza;
		private bool _completato;
		private int _passaggio;
		private int? _urgenza;

		#endregion

		#region Relations

		[Relation("ID = Fk_IDItersManager")]
		private ObjectSetHolder<Iters> _iters = new ObjectSetHolder<Iters>();

		/// <summary>
		/// Gets and sets a set of connected "Iters" persistent objects.
		/// </summary>
		[XmlIgnore]
		public ObjectSet<Iters> Iters
		{
			get { return _iters.InnerObject; }
		}

		#endregion

		#region Properties

		/// <summary>
		/// Returns the identifier of the persistent object. Don't set it manually!
		/// </summary>
		[Field("ID", AllowDBNull = false, Identifier = true, AutoNumber = true)]
		public int ID
		{
			get 
			{ 
				return _id; 
			}
			private set 
			{
				_id = value;

				OnRowChanged("ID");
			}
		}

		/// <summary>
		/// This property is mapped to the "Fk_IDDoc" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("Fk_IDDoc", AllowDBNull = false)]
		public int Fk_IDDoc
		{
			get 
			{ 
				return _fk_IDDoc; 
			}
			set 
			{
				_fk_IDDoc = value;

				OnRowChanged("Fk_IDDoc");
			}
		}

		/// <summary>
		/// This property is mapped to the "Fk_IDUser_Mittente" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("Fk_IDUser_Mittente", AllowDBNull = false)]
		public Guid Fk_IDUser_Mittente
		{
			get 
			{ 
				return _fk_IDUser_Mittente; 
			}
			set 
			{
				_fk_IDUser_Mittente = value;

				OnRowChanged("Fk_IDUser_Mittente");
			}
		}

		/// <summary>
		/// This property is mapped to the "UserName" field. Length must be between 0 and 40 characters. Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("UserName", AllowDBNull = false)]
		public string UserName
		{
			get 
			{ 
				return _userName; 
			}
			set 
			{
				if (value == null)
					throw new ArgumentNullException("value", "Value is null.");
				if (value != null && value.Length > 40)
					throw new ArgumentException("Value length must be between 0 and 40 characters.");

				_userName = value;

				OnRowChanged("UserName");
			}
		}

		/// <summary>
		/// This property is mapped to the "Titolo" field. Length must be between 0 and 150 characters. Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("Titolo", AllowDBNull = false)]
		public string Titolo
		{
			get 
			{ 
				return _titolo; 
			}
			set 
			{
				if (value == null)
					throw new ArgumentNullException("value", "Value is null.");
				if (value != null && value.Length > 150)
					throw new ArgumentException("Value length must be between 0 and 150 characters.");

				_titolo = value;

				OnRowChanged("Titolo");
			}
		}

		/// <summary>
		/// This property is mapped to the "DataCreazione" field.  
		/// Storage comment: .
		/// </summary>
		[Field("DataCreazione")]
		public DateTime? DataCreazione
		{
			get 
			{ 
				return _dataCreazione; 
			}
			set 
			{
				_dataCreazione = value;

				OnRowChanged("DataCreazione");
			}
		}

		/// <summary>
		/// This property is mapped to the "DataScadenza" field.  
		/// Storage comment: .
		/// </summary>
		[Field("DataScadenza")]
		public DateTime? DataScadenza
		{
			get 
			{ 
				return _dataScadenza; 
			}
			set 
			{
				_dataScadenza = value;

				OnRowChanged("DataScadenza");
			}
		}

		/// <summary>
		/// This property is mapped to the "Completato" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("Completato", AllowDBNull = false)]
		public bool Completato
		{
			get 
			{ 
				return _completato; 
			}
			set 
			{
				_completato = value;

				OnRowChanged("Completato");
			}
		}

		/// <summary>
		/// This property is mapped to the "Passaggio" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("Passaggio", AllowDBNull = false)]
		public int Passaggio
		{
			get 
			{ 
				return _passaggio; 
			}
			set 
			{
				_passaggio = value;

				OnRowChanged("Passaggio");
			}
		}

		/// <summary>
		/// This property is mapped to the "Urgenza" field.  
		/// Storage comment: .
		/// </summary>
		[Field("Urgenza")]
		public int? Urgenza
		{
			get 
			{ 
				return _urgenza; 
			}
			set 
			{
				_urgenza = value;

				OnRowChanged("Urgenza");
			}
		}

		#endregion

		#region IObjectNotification Members

		/// <summary>
		/// Invoked by the framework before the persistent object is populated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforePopulated(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is populated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterPopulated(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is inserted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeInsert(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is inserted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterInsert(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is updated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeUpdate(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is updated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterUpdate(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeDelete(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterDelete(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object has been marked deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeMarkDeleted(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object has been marked deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterMarkDeleted(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		#endregion

		#region ISelfContainingObject Members

		private ObjectInfo _objectInfo = null;

		/// <summary>
		/// Returns the <see cref="Opf3.ObjectInfo">ObjectInfo</see> object that contains all
		/// information required to make the persistent object
		/// <see cref="Opf3.ObjectContext">independent from any ObjectContext</see>.
		/// </summary>
		/// <value>
		/// 	<see cref="Opf3.ObjectInfo">ObjectInfo</see> object that holds the status
		/// information of the persistent object.
		/// </value>
		ObjectInfo ISelfContainingObject.ObjectInfo
		{
			get { return _objectInfo; }
			set { _objectInfo = value; }
		}

		#endregion

		#region INotifyPropertyChanged Members

		/// <summary>
		/// Invokes the "PropertyChanged" event if a property has been changed and
		/// somebody subscribed the event.
		/// </summary>
		private void OnRowChanged(string propertyName)
		{
			if (PropertyChanged != null)
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}

		/// <summary>
		/// Event is fired if a property of the persistent changed.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		#endregion
	}
}
